using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using DAO;

namespace ESWebFramework.I18N
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:ESi18nDropDownList runat=server></{0}:ESi18nDropDownList>")]
    public class ESi18nDropDownList : DropDownList
    {
        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public string TextReference1
        {
            get
            {
                String s = (String)ViewState["TextReference1"];
                return ((s == null) ? String.Empty : s);
            }

            set
            {
                ViewState["TextReference1"] = value;
            }
        }

        public string TextReference2
        {
            get
            {
                String s = (String)ViewState["TextReference2"];
                return ((s == null) ? String.Empty : s);
            }

            set
            {
                ViewState["TextReference2"] = value;
            }
        }
        public string TextReference3
        {
            get
            {
                String s = (String)ViewState["TextReference3"];
                return ((s == null) ? String.Empty : s);
            }

            set
            {
                ViewState["TextReference3"] = value;
            }
        }

        public string TextReference4
        {
            get
            {
                String s = (String)ViewState["TextReference4"];
                return ((s == null) ? String.Empty : s);
            }

            set
            {
                ViewState["TextReference4"] = value;
            }
        }

        public string TextReference5
        {
            get
            {
                String s = (String)ViewState["TextReference5"];
                return ((s == null) ? String.Empty : s);
            }

            set
            {
                ViewState["TextReference5"] = value;
            }
        }



        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            ESWebUserControl father = ESWebUserControl.checkParentType(this);
            if (father == null)
                throw (new Exception("Wrong type of Parent! The Parent control can not be casted correctly. " +
                        "The controls from the ESWebFramework library needs to be placed on a user" +
                        " control which inherits from ESWebUserControl."));
            ArrayList text = new ArrayList();
            text.Add("- - - - - - - - - ");
            if (TextReference1 != "" || TextReference1 != null)
               
            text.Add(TextBaseFactory.loadText(TextReference1, father.LangId));
            if (TextReference2 != "" || TextReference2 != null)
                
            text.Add(TextBaseFactory.loadText(TextReference2, father.LangId));
            if (TextReference3 != "" || TextReference3 != null)

                text.Add(TextBaseFactory.loadText(TextReference3, father.LangId));
            if (TextReference4 != "" || TextReference4 != null)
               
            text.Add(TextBaseFactory.loadText(TextReference4, father.LangId));
            if (TextReference5 != "" || TextReference5 != null)

                text.Add(TextBaseFactory.loadText(TextReference5, father.LangId));
            this.DataSource = text;//new string[] { "- - - - - - - - - ", TextReference1, TextReference2, TextReference3, TextReference4, TextReference5 };
            this.DataBind();
        }
    }
}
